package com.zc.auth.security.core.access.runner;

import com.zc.auth.security.core.access.meta.UrlRoleMetaDataManager;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;

import java.util.Collection;
import java.util.Map;

/**
 * 元数据加载初始化启动器
 *
 * @author zcj
 * @version 1.0.0
 * @date 2022/1/25 14:53
 */
@Slf4j
public class MetaDataInitRunner implements CommandLineRunner {

    private UrlRoleMetaDataManager urlRoleMetaDataManager;

    public MetaDataInitRunner(UrlRoleMetaDataManager urlRoleMetaDataManager) {
        this.urlRoleMetaDataManager = urlRoleMetaDataManager;
    }

    @Override
    public void run(String... args) throws Exception {
        Map<String, ? extends Collection<String>> map = urlRoleMetaDataManager.getUrlsAndRolesMap();
        log.info(String.format("接口角色权限表加载完成！共%s个url patten", map.size()));
    }
}
